package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.common.core.constant.enums.NormalAuditActionStatusEnum;
import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.supervision.dto.create.SpWarningCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.SpWarningResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.SpWarningUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.SpWarningEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface SpWarningConvert {
    SpWarningConvert INSTANCE = Mappers.getMapper(SpWarningConvert.class);

    SpWarningResultDTO convert(SpWarningEntity s);

    SpWarningEntity createTo(SpWarningCreateDTO s);

    SpWarningEntity update(SpWarningUpdateDTO s);

    default SpWarningEntity create(SpWarningCreateDTO s, Long tenantId, NormalAuditActionStatusEnum action) {
        SpWarningEntity entity = createTo(s);
        entity.setTenantId(tenantId);
        entity.setLcbh(CodeUtils.entrustCode());
        entity.setPreAction(action);
        return entity;
    }
}
